package Demo4;
abstract class Animal{
    //字段 public static final
    int age;
    String name;

    //方法 public abstract    构造是public
    public Animal(int age, String name) {
        this.age = age;
        this.name = name;
    }
    public abstract void eat();
}
interface IRun {
    void run();
}
class Dog extends Animal implements IRun{   //继承动物类+跑的功能
    //构造+重写
    public Dog(int age, String name) {
        super(age, name);
    }
    @Override
    public void eat() {
        System.out.println(name+"吃狗粮！");
    }

    @Override
    public void run() {
        System.out.println(name+"正在跑!");
    }
}
public class Test {
    public static void func(Animal animal){
        animal.eat();
    }
    public static void run(IRun Run){
        Run.run();
    }
    public static void main(String[] args) {
        func(new Dog(10,"狗子"));
        run(new Dog(10,"狗子"));
    }
}
